#:include kv/options_widgets.kv

<MenuLayout@BoxLayout>
    padding: [20, 0]
    y: 50
    height: 80
    size_hint: 1, None
    orientation: 'horizontal'

<BaseTextInput@LabelB>
    bcolor: 0.3, 0.3, 0.3, 0.7
    color: 0.9, 0.9, 0.9, 1

<BaseNumberInput@NumberInput>
    background_color: 0.3, 0.3, 0.3, 0.7
    foreground_color: 0.9, 0.9, 0.9, 1

<SeedingCheckBox@CheckBox>
    width: 30
    size_hint_x: None
    group: 'seedingtype'
    allow_no_selection: False
    seeding_type: ''

<SeedingLabel@Label>
    valign: 'middle'
    text_size: self.size
    halign: 'left'

<SpeedLabel@Label>
    size_hint_x: None
    width: 160
    valign: 'middle'
    text_size: self.size
    halign: 'left'

<SpeedInput@BaseNumberInput>
    size_hint: None, None
    width: 80
    height: 30
    multiline: False
    text_size: self.width, self.height
    font_size: 18
    valign: 'middle'
    pos_hint: {'center_y': 0.5}
    padding: [5, ( self.height - self.line_height ) / 2]

# Settings contents
<ModsBox@BoxLayout>
    padding: 20
    orientation: 'vertical'
    size_hint: 1, None
    screen: None
    top: (root.screen.top if root.screen else 0)
    height: 504

    BoxLayout:  # Mods location
        id: mod_location_selection
        orientation: 'horizontal'
        size_hint_y: None
        height: 30
        Label:
            text: 'Mods Directory:'
            text_size: self.width, self.height
            halign: 'left'
            width: 200
            size_hint_x: None
            pos_hint: { 'center_y': 0.7 } # Change or remove this if you're changing the label's text

        BaseTextInput:
            id: path_text_input
            text: ''
            shorten: True
            text_size: self.width, self.height
            font_size: 20
            height: 30
            size_hint: 1, None
            valign: 'middle'
            padding: 10, 0

        Button:
            size_hint: None, None
            height: 30
            text: 'Choose Path'
            on_release: root.screen.controller.on_choose_path_button_release(self)

        Button:
            size_hint: None, None
            height: 30
            text: 'Open Folder'
            on_release: app.open_hyperlink(path_text_input.text)

    BoxLayout:  # Divider
        BoxLayout:  # First column
            orientation: 'vertical'

            Label:
                size_hint_y: None
                text_size: self.size
                halign: 'left'
                valign: 'middle'
                height: 30
                text: 'Seed (share/upload) finished mods:'

            # Seeding mods radio buttons
            BoxLayout:
                size_hint_y: None
                height: 25
                SeedingCheckBox:
                    id: sbox_always
                    seeding_type: 'always'
                SeedingLabel:
                    text: 'Always'

            BoxLayout:
                size_hint_y: None
                height: 25
                SeedingCheckBox:
                    id: sbox_while_not_playing
                    seeding_type: 'while_not_playing'
                SeedingLabel:
                    text: 'While not playing'

            BoxLayout:
                size_hint_y: None
                height: 25
                SeedingCheckBox:
                    id: sbox_never
                    seeding_type: 'never'
                SeedingLabel:
                    text: 'Never'

            Label:  # Seeding message to users
                size_hint_y: None
                text_size: self.size
                halign: 'left'
                valign: 'middle'
                height: 100
                text: '[i]Note: Seeding (uploading mods to other players) helps us tremendously.\nWe don\'t have infinite bandwidth and by sharing yours you can help us speed up the downloads for everyone.\nSharing is caring :)[/i]'
                markup: True

            BoxLayout:  # Upload speed
                orientation: 'horizontal'
                height: 50
                size_hint: 1, None
                SpeedLabel:
                    text: 'Max upload speed:'
                SpeedInput:
                    id: max_upload_speed_input
                Label:
                    width: 10
                    size_hint_x: None
                SpeedLabel:
                    text: 'KB/s   (0 = unlimited)'

            Label:
                size_hint_y: None
                text_size: self.width, None#self.size
                halign: 'left'
                valign: 'middle'
                height: 0 if self.disabled else self.texture_size[1]
                opacity: 0 if self.disabled else 1
                text: '[i][size=10][color=#FF0000]Note: Setting a very low upload speed value will also slow your download speed down!\nIf you don\'t want to upload, set seeding to "Never", instead.[/color][/size][/i]'
                markup: True
                disabled: False if max_upload_speed_input.text and (0 < int(max_upload_speed_input.text) <= 20) else True

            BoxLayout:  # Download speed
                orientation: 'horizontal'
                size_hint: 1, None
                height: 50
                SpeedLabel:
                    text: 'Max download speed:'
                SpeedInput:
                    id: max_download_speed_input
                Label:
                    width: 10
                    size_hint_x: None
                SpeedLabel:
                    text: 'KB/s   (0 = unlimited)'

            Widget:  # To move everything to the top

        BoxLayout:  # Second column
            orientation: 'vertical'
            padding: 20
            Label:
                text:
                    '''Mods:
                    [i][size=12]Note: The launcher will try to find all missing mods automatically when installing[/size][/i]'''
                markup: True
                text_size: self.parent.size[0], None
                size: self.texture_size
                size_hint: None, None

            ModListScrolled:
                id: mods_list
                directory_selection_callback: (root.screen.controller.request_mods_recheck if root.screen else None)
                mod_selection_callback: (root.screen.controller.request_mods_recheck if root.screen else None)
                height: 350

            FloatLayout:
                LabelB:
                    id: mods_list_notification
                    text: 'Disabled while checking\ndownloading or seeding'
                    bcolor: 0.2, 0.2, 0.2, 0.5
                    color: 0.5, 0.5, 0.5, 1
                    size: mods_list.width, mods_list.visible_content_height
                    size_hint: None, None
                    x: mods_list.x
                    y: mods_list.y + mods_list.height - mods_list.visible_content_height
                    opacity: int(mods_list.disabled)
